#include<bits/stdc++.h>
using namespace std ;
template<class T>void read(T &x){
	x=0;int f=0;char ch=getchar();
	while(ch<'0'||ch>'9'){f|=(ch=='-');ch=getchar();}
	while(ch<='9'&&ch>='0'){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
	x=f?-x:x;
	return ;
}
char k[10];
int main(int argc,char *argv[])
{
    freopen("a.in","r",stdin);
    freopen("a.dot","w",stdout);
    int a,b;
    bool x;
	if(!argv[1]) x=1;
	if(!x) strcpy(k,argv[1]);
    if(argc>=3) return 0 ;
    scanf("%d %d",&a,&b);
    printf("digraph G{\n");
    for(int i=1;i<=b;i++){
        int u,v;
        scanf("%d%d",&u,&v);
        printf("    %d -> %d",u,v);
        if(k[0]=='q'||k[0]=='w')
		{
			printf(" [");
			if(k[0]=='q'&&k[1]=='w'){
                int c;read(c);
				printf("label=\" %d \" ",c);
				printf("arrowhead=\"none\" ");
			}
			else if(k[0]=='q'){
                int c;read(c);
				printf("label=\" %d \" ",c);
			}
			else if(k[0]=='w') printf("arrowhead=\"none\" ");
			printf(" ];");
        }
        else printf(";");
		printf("\n");
    }
    printf("}");
    return 0 ;
}